package sunsun.xiaoli.jiarebang.logincontroller;


import com.itboye.pondteam.utils.Const;
import com.itboye.pondteam.utils.LogUtils;
import com.itboye.pondteam.utils.SPUtils;
import sunsun.xiaoli.jiarebang.app.App;

/**
 * 登录相关控制类--状态模式</br></br>
 * <p>
 * 登录成功后调用setLoginState(new LoginedState());</br></br>
 * 退出登录后调用setLoginState(new UnLoginState());</br></br>
 * 进入主Activity前一定要设置一次，要么登录要么未登录</br></br>
 *
 * @author Mr.w
 */
public class LoginController {

    private static ILoginState loginState = new UnLoginState();
//    private static PushAgent mPushAgent;

    public static void setLoginState(ILoginState loginState) {

        LoginController.loginState = loginState;

        if (loginState instanceof UnLoginState) {
            LogUtils.v("Login", "未登录");
        } else if (loginState instanceof LoginedState) {
            LogUtils.v("bytag", "已登录。。。");
            final String uid = (String) SPUtils.get(App.getInstance(), null, Const.UID, "");
//            App.getInstance().mPushAgent.onAppStart();
//            App.getInstance().mPushAgent.addAlias(uid, BuildConfig.UMENG_ALIAS, (arg0, arg1) -> {
//                if (!arg0) {
//
//                }
//                System.out.println(arg0 + "arg222" + arg1 + "  UId" + uid + " alias:" + BuildConfig.UMENG_ALIAS);
//            });
        }
    }
}
